<#compress>
<!DOCTYPE html>
<!-- saved from url=(0074)http://www.apiwx.com/index.php?ac=alw&c=o7MB9ji5fQRsE0ZoVAMU7SlnRyMI&tid=5 -->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport"
          content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="幸运大转盘">
    <title>幸运大转盘</title>
    <link href="${ctx}/static/mobileweb/game/2/activity-style.css?_=${.now?string('yyyy-MM-dd')}" rel="stylesheet" type="text/css">
</head>

<body class="activity-lottery-winning">
<div class="main">
<#--<script type="text/javascript">
    var loadingObj = new loading(document.getElementById('loading'), {radius: 20, circleLineWidth: 8});
    loadingObj.show();
</script>-->
    <div id="outercont">
        <div id="outer-cont">
            <div id="outer"><img src="${ctx}/static/mobileweb/game/2/activity-lottery-1.png" width="310px"></div>
        </div>
        <div id="inner-cont">
            <div id="inner"><img src="${ctx}/static/mobileweb/game/2/activity-lottery-2.png"></div>
        </div>
    </div>
    <div class="content">
        <div class="boxcontent boxyellow" id="checkGame" style="display:none">
            <div class="box">
                <div class="title-green"><span>&nbsp;提醒</span></div>
                <div class="Detail">
                    <p id="checkmsg"></p>
                    <#--<input class="pxbtn" id="back-btn" name="back-btn" type="button" value="返回游戏列表">-->
                    <a style="text-decoration: none;" class="pxbtn" href="${ctx}/mobileweb/game?mid=${mid!}&wxno=${wxno!}">返回游戏列表</a>
                </div>
            </div>
        </div>

        <div class="boxcontent boxyellow" id="result" style="display:none">
            <div class="box">
                <div class="title-green"><span id="win_tip"></span></div>
                <div class="Detail">
                    <p>你中了：<span class="red" id="prizetype"></span></p>
                    <p>你的兑奖SN码：<span class="red" id="sncode"></span></p>
                    <p>
                        <input class="pxbtn" id="reload-btn" name="reload-btn" type="button" value="再玩一次">
                    </p>
                </div>
            </div>
        </div>
        <div class="boxcontent boxyellow">
            <div class="box">
                <div class="title-green"><span>奖项设置：</span></div>
                <div class="Detail">
                    <#--<#list gameAwardses as ga>
                        <p>
                            ${ga.awardsName}： ${ga.giftName}。
                            <#if ga.awardsSize?? && ga.awardsSize != 0>
                            奖品数量：${ga.awardsSize}
                            </#if>
                        </p>
                    </#list>-->
                    <p>
                        礼品：武艺10张签名照片/海报<br/>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  10本新书《别太想我哦》 <br/>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  1000份10中南币 <br/>
                    </p>
                </div>
            </div>
        </div>
        <div class="boxcontent boxyellow">
            <div class="box">
                <div class="title-green">活动说明：</div>
                <div class="Detail">
                    <p class="red">
                        <#if gameRule.free_times??>
                            大转盘游戏每日可以免费玩${gameRule.free_times}次,如果免费次数没用完重新进入本页面可以再玩!
                        </#if>
                        你今天已经玩了${todayPlayTimes!}次
                    </p>
                    <p> ${game.remark!} </p>
                </div>
            </div>
        </div>
    </div>

</div>
<script src="${ctx}/static/mobileweb/game/2/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
    var vname = {
        <#if gameAwardses??>
            <#list gameAwardses as ga>
                '${ga.giftId}' : ${ga_index}
                <#if ga_has_next>,</#if>
            </#list>
        </#if>
    };

    var todayPlayTimes = ${todayPlayTimes};
    var freeTimes = ${gameRule.free_times};

    var consume = "${gameRule.consume?string('true', 'false')}";
    var integral = "${member.integral!}";
    var useIntegral = "${gameRule.integral!}";

    var useVirtualCurrency = "${gameRule.use_virtual_currency?string('true', 'false')}";
    var currency = "${member.currency!}";
    var virtualCurrency = "${gameRule.virtual_currency!}";


    function checkGame() {
        if (freeTimes>todayPlayTimes) {
            return true;
        } else {
            var lessIntegral = false;
            var lessCurrency = false;
            if (useVirtualCurrency === "true") { //可以使用中南币
                if (currency>=virtualCurrency) { //可以扣减
                    return window.confirm("您已经没有免费机会，本次游戏需要扣" + virtualCurrency + "中南币，是否继续？");
                    //return true;
                } else {
                    lessCurrency = true;
                }
            }

            if (consume === "true") { //可以使用积分
                if (integral >= useIntegral) { //当前积分满足使用积分
                    return window.confirm("您已经没有免费机会，本次游戏需要扣" + useIntegral + "积分，是否继续？");
                    //return true;
                } else {
                    lessIntegral = true;
                }
            }


            if (consume === "true" && useVirtualCurrency === "true") { //可以使用积分和中南币

                if (lessIntegral && lessCurrency) {
                    $("#checkmsg").html("对不起，您的积分，中南币不够玩本次游戏。");
                }
            } else {
                if(lessIntegral){ //尝试使用过积分，积分不够
                    $("#checkmsg").html("对不起，您的积分不够玩本次游戏。");
                } else if(lessCurrency) {//尝试使用过中南币，积分不够

                    $("#checkmsg").html("对不起，您的中南币不够玩本次游戏。");
                } else {//计算错误
                    $("#checkmsg").html("没有免费次数了，明天继续吧。");
                }
            }

            $("#checkGame").slideToggle(500);
            return false;
        }
    }

    $(function () {
        window.requestAnimFrame = (function () {
            return window.requestAnimationFrame ||
                    window.webkitRequestAnimationFrame ||
                    window.mozRequestAnimationFrame ||
                    window.oRequestAnimationFrame ||
                    window.msRequestAnimationFrame ||
                    function (callback) {
                        window.setTimeout(callback, 1000 / 60)
                    }
        })();
        var totalDeg = 360 * 3 + 0;
        var steps = [];
        var lostDeg = [36, 96, 156, 216, 276, 336];
        //var prizeDeg = [6, 66, 126, 186, 246, 306];
        var prizeDeg = [6, 126, 246, 66, 186, 306];

        var prize, sncode;
        var count = 0;
        var now = 0;
        var a = 0.01;
        var outter, inner, timer, running = false;

        function countSteps() {
            var t = Math.sqrt(2 * totalDeg / a);
            var v = a * t;
            for (var i = 0; i < t; i++) {
                steps.push((2 * v * i - a * i * i) / 2)
            }
            steps.push(totalDeg)
        }

        function step() {
            outter.style.webkitTransform = 'rotate(' + steps[now++] + 'deg)';
            outter.style.MozTransform = 'rotate(' + steps[now++] + 'deg)';
            if (now < steps.length) {
                requestAnimFrame(step)
            } else {
                //running = false;
                setTimeout(function () {
                    $("#result").slideToggle(500);
                }, 200)
            }
        }

        function start(deg) {
            deg = deg || lostDeg[parseInt(lostDeg.length * Math.random())];
            running = true;
            clearInterval(timer);
            totalDeg = 360 * 5 + deg;
            steps = [];
            now = 0;
            countSteps();
            requestAnimFrame(step)
        }

        window.start = start;
        outter = document.getElementById('outer');
        inner = document.getElementById('inner');
        i = 10;
        $("#inner").click(function () {
            if (running)return;
            if (prize)return;
            if (!checkGame()) {
                return;
            }
            running = true;
            gameStart();
        });

        $("#back-btn").click(function() {
            window.history.back();
        });

        $("#reload-btn").bind("click", function () {
            window.location.reload();
        });

        function gameStart() {
            $.ajax({
                url: "${ctx}/mobileweb/game/dispose",
                data: "mid=${mid!}&wxno=${wxno}&gid=${game.id!}",
                beforeSend: function () {
                    running = true;
                    timer = setInterval(function () {
                        i += 5;
                        outter.style.webkitTransform = 'rotate(' + i + 'deg)';
                        outter.style.MozTransform = 'rotate(' + i + 'deg)'
                    }, 1);
                },
                success: function (data) {
                    if(data.status == 'OK') {
                        var data2 = data.data;
                        var name =data2.awardName;
                        var giftId =data2.giftId;
                        var sncode = data2.sncode;
                        var index = vname[giftId];
                        if (data2.accept == 1) {
                            $('#sncode').parent().hide();
                        } else {
                            document.getElementById('sncode').innerHTML = data2.sncode;
                        }
                        $("#sncode").text(sncode);
                        $("#prizetype").text(name);
                        $("#win_tip").html("&nbsp;恭喜你");

                        prize = index + 1;

                        start(prizeDeg[index]);
                    } else {
                        $("#sncode").parent().text("");
                        $("#prizetype").parent().text(data.message);
                        $("#win_tip").html("&nbsp;很遗憾");
                        prize = null;
                        start()
                    }
                    running = true;
                    count++
                },
                error: function () {
                    prize = null;
                    start();
                    running = true;
                    count++
                },
                timeout: 4000
            });
        }
    });




</script>


</body>
</html>
</#compress>